package com.sunshine.demo.service;

import com.alibaba.fastjson.JSON;
import com.sunshine.demo.annotation.DoSomething;
import com.sunshine.demo.mapper.UserMapper;
import com.sunshine.demo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author: sanglei
 * @date: 2018-11-01 9:16
 * @description:
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    private static final String CACHE_NAME = "sunshine_sunny_";
    @DoSomething(key = "#id",cacheName = CACHE_NAME,needLog = true)
    public User query(long id){
        User user = userMapper.selectByPrimaryKey(id);
        System.out.println("从数据库中获取用户信息");
        return user;
    }
}
